package com.medical.vo;

import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class GenericResult<T> {
    Integer code;
    String message;
    T data;

    public static <T> GenericResult<T> successData(T data) {
        GenericResult<T> result = new GenericResult<>();
        result.setCode(200);
        result.setMessage("SUCCESS");
        result.setData(data);
        return result;
    }

    public static <T> GenericResult<T> success() {
        GenericResult<T> result = new GenericResult<>();
        result.setCode(1);
        result.setMessage("SUCCESS");
        return result;
    }

    public static <T> GenericResult<T> error(String message) {
        GenericResult<T> result = new GenericResult<>();
        result.setCode(0);
        result.setMessage(message);
        return result;
    }
}
